#ifndef MKV_PLAYER_H
#define MKV_PLAYER_H

#include <filesystem>
#include <functional>
#include <gst/gst.h>
#include <gst/app/app.h>
#include <thread>
#include <atomic>

class MKVPlayer
{
  public:
    MKVPlayer();
    virtual ~MKVPlayer();
    void Start(std::filesystem::path file,bool callbackMode);
    void Stop();
    bool GetPlayStatus();
    void GetNewImage(char* data); //block call
    std::function<void(const char* data,int width,int height)> funcNewImageCallback;
    std::function<void()> funcStopCallback;
  private:
    std::atomic_bool PlayFlag=false;
    friend void pad_added_handler (GstElement *src, GstPad *pad, gpointer data);
    GstElement *filesrc,*matroskademux,*h264parse,*nvh264dec,*cudaconvert,*cudadownload,*appsink;
    GstElement *pipeline;
    std::thread ReceiveDataThread;
};

#endif
